package top.leyi.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.leyi.IService.IJobjService;
import top.leyi.entity.Job;
import top.leyi.entity.SQLUtil;
import top.leyi.entity.user.User;
import top.leyi.mapper.JobMapper;

import java.util.List;

@Service
public class JobServiceImpl implements IJobjService {
    private int LIMIT = 25;
    @Autowired
    JobMapper jobMapper;
    @Override
    public List<Job> queruAllJobs(int page, User user) {
        SQLUtil sqlUtil = new SQLUtil();
        sqlUtil.setOffset((page - 1) * LIMIT);
        sqlUtil.setLimit(LIMIT);
        return jobMapper.queryAllJob(sqlUtil);
    }

    @Override
    public void addJob(Job job, User user) {
         jobMapper.addJob(job);
    }

    @Override
    public void deleteJob(Job job, User user) {
         jobMapper.deleteJob(job.getId());
    }
}
